package com.It;
//求累加和
import java.util.Scanner;
public class GetSum {
    public static int getSum(int num){
        int count = 0;
        int i=1;
        while(i<=num){
            count+=i;
            i++;
        }
        return count;
    }
    public static void main(String[] args) {
        System.out.println("输入需要求一个累加和的数字");
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
//        GetSum gs = new GetSum();
//        int a = gs.getSum(num);
        int b = getSum(num);
//        System.out.println("1到"+num+"的累加和为:"+a);
        System.out.println("1到"+num+"的累加和为:"+b);
    }
}
